<!--
 * @version: 
 * @Author: yu
 * @Date: 2023-07-01 22:03:28
 * @LastEditors: Andy
 * @LastEditTime: 2023-07-03 20:20:05
-->
<template>
    <div>
        <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" row-key="id" border
            :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">

            <el-table-column prop="title" label="活动名称"></el-table-column>

            <el-table-column prop="status" label="状态">
                <template v-slot="item">
                    <el-button v-if="item.row.status === 1" type="success" size="small">启用</el-button>
                    <el-button v-else type="danger" size="small">禁用</el-button>
                </template>
            </el-table-column>

            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button @click="edit(scope.row.id)" type="primary" size="small">编辑</el-button>
                    <el-button @click="del(scope.row.id)" type="danger" size="small">删除</el-button>
                </template>
            </el-table-column>

        </el-table>
    </div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import { seckdelete } from '@/request/api'
import { successAlert } from '@/utils/alert'
export default {
    data() {
        return {


        }
    },
    methods: {
        ...mapActions({
            requestSeckill: 'seckill/listActions'
        }),
        //编辑
        edit(id) {
            this.$emit('edit', id)
        },
        //删除
        del(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                seckdelete({ id }).then(res => {
                    // console.log(res);
                    if (res.code === 200) {
                        //消息提示
                        successAlert(res.msg)
                        //更新列表
                        this.requestSeckill()

                    }
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        }
    },
    mounted() {
        this.requestSeckill()

    },
    watch: {},
    computed: {
        ...mapGetters({
            tableData: 'seckill/list'
        })
    },
    filters: {},
    components: {}
}
</script>
<style scoped></style>